﻿#!/usr/bin/env python
# -*- coding: utf-8 -*-

'inheritance example'

__author__='zhaoxp'

class Animal(object):
	def run(self):
		print "Animal is running"
	
class Dog(Animal):
	def run(self):
		print "Dog is running"

class Cat(Animal):
	def run(self):
		print "Cat is running"
		
def run_twice(animal):
	animal.run()
	animal.run()
	
if __name__=="__main__":
	print "inheritance example"
	a=Animal()
	dog=Dog()
	cat=Cat()
	a.run()
	dog.run()
	cat.run()
	print "isinstance(a,Animal) =",isinstance(a,Animal)
	print "isinstance(dog,Animal) =",isinstance(dog,Animal)
	print "isinstance(cat,Animal) =",isinstance(cat,Animal)
	print "isinstance(a,Dog) =",isinstance(a,Dog)
	print "isinstance(dog,Dog) =",isinstance(dog,Dog)
	print "isinstance(cat,Dog) =",isinstance(cat,Dog)
	print "isinstance(a,Cat) =",isinstance(a,Cat)
	print "isinstance(dog,Cat) =",isinstance(dog,Cat)
	print "isinstance(cat,Cat) =",isinstance(cat,Cat)
	run_twice(Animal())
	run_twice(Dog())